<?
	class classSession {
		public function __construct($crm,$cfg=array()) {
		
		
		
			ini_set('session.name', isset($cfg->name)?$cfg->name:'phpNMS');
			ini_set('session.use_cookies', 1);
			ini_set('session.auto_start', 1);		
			ini_set('session.cache_expire',isset($cfg->lifetime)?$cfg->lifetime:43200);
			ini_set('session.cookie_lifetime',isset($cfg->lifetime)?$cfg->lifetime:43200);
			ini_set('session.cookie_domain', isset($cfg->domain)?$cfg->domain:$_SERVER['HTTP_HOST']);				
			ini_set('session.gc_maxlifetime', isset($cfg->lifetime)?$cfg->lifetime:43200);
			ini_set('session.cookie_lifetime', isset($cfg->lifetime)?$cfg->lifetime:43200);
			// Check for Passed Session ID
			if (isset($_GET["PHPSESSID"])) {
				session_id($_GET["PHPSESSID"]);	
			}  else if (isset($_POST["PHPSESSID"])) {
				session_id($_POST["PHPSESSID"]);	
			}
			session_start();
			if (!isset($_SESSION['Cache Control'])) {
				$_SESSION['Cache Control'] = array();
			}
			if (isset($_GET['logout'])) {				
				$this->destroy();
				header('Location: /');
			}
		}	
		public function destroy() {
			@session_start();
			if (isset($_COOKIE['myphp'])) {
				setcookie('myphp', '', time()-42000, '/');
			}
			$_SESSION = array();
			unset($_SESSION);			
			session_destroy();	
		}	
	}
?>